<!-- 商品详情-标签页组件 -->
<template>
    <div class="goods-tabs">
        <nav>
            <a :class="{active:activeName ==='Detail'}" @click="clickTab('Detail')" href="javascript:;">商品详情</a>
            <a :class="{active:activeName ==='Comment'}" @click="clickTab('Comment')" href="javascript:;">商品评价<span>({{goods.commentCount}})</span></a>
        </nav>
        <!-- 切换展示商品详情 or商品评论 -->
        <component :is="'Goods'+ activeName"></component>
    </div>
</template>
 
<script>
import { ref } from 'vue'
import GoodsComment from './goods-comment.vue'
import GoodsDetail from './goods-detail.vue'
export default {
    name: 'GoodsTabs',
    props:{
        goods:{
            type:Object,
            default:()=>{}
        }
    },
    components:{
        GoodsComment,GoodsDetail
    },
    setup() {
        let activeName = ref('Detail')
        const clickTab = (name) => {
            activeName.value = name
        }
        return {
            activeName, clickTab
        }
    }
}
</script>
<style lang="less" scoped>
.goods-tabs {
    min-height: 600px;
    background: #fff;

    nav {
        height: 70px;
        line-height: 70px;
        display: flex;
        border-bottom: 1px solid #f5f5f5;

        a {
            padding: 0 40px;
            font-size: 18px;
            position: relative;

            >span {
                color: @priceColor;
                font-size: 16px;
                margin-left: 10px;
            }

            &:first-child {
                border-right: 1px solid #f5f5f5;
            }

            &.active {
                &::before {
                    content: "";
                    position: absolute;
                    left: 40px;
                    bottom: -1px;
                    width: 72px;
                    height: 2px;
                    background: @xtxColor;
                }
            }
        }
    }
}
</style>